package com.test.study.ToolsUtils.suanfa;

/**
 * 性能比较好的排序
 * 
 * @author huyong
 *
 */
public class MaoPao {
	public static void main(String[] args) {
		int array[] = { 23, 45, 67, 23, 45, 1, 7, 8, 34, 454, 0 };
		maoPaoSort(array);
		for (int i : array) {
			System.out.println(i);
		}

	}

	/**
	 * 一个比较好的冒泡排序 huyong
	 * 
	 * @param array Jun 27, 2019
	 */
	public static void maoPaoSort(int array[]) {
		for (int i = 0; i < array.length - 1; i++) {
			boolean isSort = true;
			for (int j = 0; j < array.length - 1 - i; j++) {

				if (array[j] > array[j + 1]) {
					isSort = false;
					int temp = 0;
					temp = array[j];
					array[j] = array[j + 1];
					array[j + 1] = temp;
				}
			}
			if (isSort) {
				break;
			}
		}
	}
}
